<?php

namespace common\models\member;

use Yii;

/**
 * This is the model class for table "{{%member_market_log}}".
 *
 * @property int $id
 * @property int $user_id 用户ID
 * @property int $member_id
 * @property string $model 内部模型
 * @property int $model_id 内部模型ID
 * @property int $model_user_id 内部模型用户ID
 * @property int $price 佣金金额（分）
 * @property int $experience 经验值
 * @property int $status 状态
 * @property int $created_at 创建时间
 * @property int $updated_at 最后更新时间
 * @property int $deleted_at 删除时间
 */
class MemberMarketLog extends \common\db\ActiveRecord {

    use \common\traits\relation\UserData;

    CONST STATUS_ACTIVE = 10;
    CONST STATUS_DEFAULT = 0;
    const MODEL_SHOP = 'ShopOrder';

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%member_market_log}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['user_id', 'member_id', 'model_id', 'model_user_id', 'price', 'experience', 'status', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
            [['model'], 'string', 'max' => 20],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'user_id' => '会员用户ID',
            'member_id' => 'Member ID',
            'model' => '内部模型',
            'model_id' => '内部模型ID',
            'model_user_id' => '内部模型用户ID',
            'price' => '佣金金额（分）',
            'experience' => '经验值',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '最后更新时间',
            'deleted_at' => '删除时间',
        ];
    }

    public function getOrderUser() {
        return $this->hasOne(\common\logics\UserMinLogic::class, ['id' => 'model_user_id']);
    }

}
